#! python
import Structure
import Chain
import Residue
import Atom

if __name__ == '__main__':

    ato   = Atom.Atom()
    res   = Residue.Residue()
    cha   = Chain.Chain()
    mystr = Structure.Structure()
 
    fname="test.psf"
    ipsf=file(fname,"r")
    nato=0
    while nato == 0:
        ll=ipsf.readline()
        if "!NATOM" in ll:
            cols=ll.split()
            nato=cols[0]
    print nato
    prev_resid=0
    fake=[]
    for ii in range(int(nato)):
        ll=ipsf.readline()
        cc=ll.split()

	index   = cc[0]
	segid   = cc[1]
	resid   = cc[2]
	resname = cc[3]
	name    = cc[4]
	typeid  = cc[5]   
	charge  = cc[6]
	mass    = cc[7]
		
	if ( resid != prev_resid ):
		res.set ( resname, resid, segid )
#		cha.add( res )
 			
        ato.set ( index, segid, resid, resname, name, typeid, charge, mass )
# 	res.add ( ato )
	fake.append( resname )
	print fake
		
#	if ( segid != prev_segid ):
#		mystr.add( cha )	
#
#		
#	prev_resid = resid
#
#        print ii+1, myatom.number() ,myatom.mass(), myatom.resname(), myres.resid () ,myres.resname(), myres.segid()
